<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}慢性病风险预测与智能干预系统{% endblock %}</title>
    
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <!-- ECharts -->
    <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.0/dist/echarts.min.js"></script>
    
    <style>
        :root {
            --primary-color: #2c3e50;
            --secondary-color: #3498db;
            --success-color: #27ae60;
            --warning-color: #f39c12;
            --danger-color: #e74c3c;
            --light-bg: #f8f9fa;
        }
        
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: var(--light-bg);
        }
        
        .navbar-brand {
            font-weight: bold;
            color: var(--primary-color) !important;
        }
        
        .card {
            border: none;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }
        
        .card-header {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: white;
            border-radius: 10px 10px 0 0 !important;
            font-weight: bold;
        }
        
        .btn-primary {
            background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
            border: none;
            border-radius: 25px;
            padding: 10px 25px;
        }
        
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
        }
        
        .risk-low {
            color: var(--success-color);
            background-color: rgba(39, 174, 96, 0.1);
            padding: 5px 15px;
            border-radius: 20px;
            font-weight: bold;
        }
        
        .risk-medium {
            color: var(--warning-color);
            background-color: rgba(243, 156, 18, 0.1);
            padding: 5px 15px;
            border-radius: 20px;
            font-weight: bold;
        }
        
        .risk-high {
            color: var(--danger-color);
            background-color: rgba(231, 76, 60, 0.1);
            padding: 5px 15px;
            border-radius: 20px;
            font-weight: bold;
        }
        
        .chart-container {
            height: 400px;
            width: 100%;
        }
        
        .loading {
            display: none;
            text-align: center;
            padding: 20px;
        }
        
        .spinner-border {
            color: var(--secondary-color);
        }
        
        .feature-importance-bar {
            height: 20px;
            background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
            border-radius: 10px;
            margin: 5px 0;
            transition: width 0.3s ease;
        }
        
        .intervention-card {
            border-left: 4px solid var(--secondary-color);
            background: white;
            padding: 15px;
            margin: 10px 0;
            border-radius: 5px;
        }
        
        .footer {
            background-color: var(--primary-color);
            color: white;
            padding: 20px 0;
            margin-top: 50px;
        }
        
        .form-control:focus {
            border-color: var(--secondary-color);
            box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
        }
        
        .alert {
            border-radius: 10px;
            border: none;
        }
        
        .table {
            border-radius: 10px;
            overflow: hidden;
        }
        
        .table thead th {
            background-color: var(--primary-color);
            color: white;
            border: none;
        }
    </style>
    
    {% block extra_css %}{% endblock %}
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
        <div class="container">
            <a class="navbar-brand" href="/">
                <i class="fas fa-heartbeat me-2"></i>
                慢性病风险预测系统
            </a>
            
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/">
                            <i class="fas fa-home me-1"></i>首页
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/doctor">
                            <i class="fas fa-user-md me-1"></i>医生端
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/user">
                            <i class="fas fa-user me-1"></i>用户端
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 主要内容 -->
    <main class="container mt-4">
        {% block content %}{% endblock %}
    </main>

    <!-- 页脚 -->
    <footer class="footer">
        <div class="container text-center">
            <p class="mb-0">
                <i class="fas fa-copyright me-1"></i>
                2024 慢性病风险预测与智能干预系统 | 
                基于多源数据的AI健康管理平台
            </p>
            <p class="mb-0 mt-2">
                <small>
                    技术支持：XGBoost + LSTM + SHAP | 
                    医学依据：中国高血压防治指南、中国2型糖尿病防治指南
                </small>
            </p>
        </div>
    </footer>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    
    <!-- 通用JavaScript -->
    <script>
        // 显示加载状态
        function showLoading(element) {
            $(element).html('<div class="loading"><div class="spinner-border" role="status"><span class="visually-hidden">加载中...</span></div><p class="mt-2">正在分析数据...</p></div>');
        }
        
        // 隐藏加载状态
        function hideLoading(element, content) {
            $(element).html(content);
        }
        
        // 显示提示消息
        function showAlert(message, type = 'info') {
            const alertHtml = `
                <div class="alert alert-${type} alert-dismissible fade show" role="alert">
                    ${message}
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
            `;
            $('main .container').prepend(alertHtml);
            
            // 3秒后自动消失
            setTimeout(() => {
                $('.alert').fadeOut();
            }, 3000);
        }
        
        // 格式化风险等级显示
        function formatRiskLevel(level) {
            const levelMap = {
                'low': '<span class="risk-low">低风险</span>',
                'medium': '<span class="risk-medium">中等风险</span>',
                'high': '<span class="risk-high">高风险</span>'
            };
            return levelMap[level] || '<span class="risk-low">未知</span>';
        }
        
        // 格式化概率显示
        function formatProbability(prob) {
            return (prob * 100).toFixed(1) + '%';
        }
        
        // 获取风险等级颜色
        function getRiskColor(level) {
            const colorMap = {
                'low': '#27ae60',
                'medium': '#f39c12',
                'high': '#e74c3c'
            };
            return colorMap[level] || '#95a5a6';
        }
    </script>
    
    {% block extra_js %}{% endblock %}
</body>
</html>
